<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admhtmlindexall.php,v $ 
 * $Date: 2005/08/29 15:02:37 $ 
 * $Revision: 1.2 $ 
 * 
 * ********* CVS HEADER ********* 
 */
$query = "TRUNCATE TABLE rportal_moteur_url"; 
@rportalrequete($query) or rportalerreur("ERREUR : $query","?op=");
require_once(get_path_module("recherche.indexation"));
require_once('module/TPLN/TPLN.php');
$TPLN = new TPLN;
$TPLN->Open($op_basepath.'tpl/admhtmlindexall.html');
$TPLN->IncludeFile("header","environnement/{$session['environnement']}/header.php"); 
$TPLN->IncludeFile("footer","environnement/{$session['environnement']}/footer.php");
$i = 0;
$class="liste_impaire"; 

$query = "SELECT html.*,html_type.nom AS type_nom FROM html,html_type WHERE html.type=html_type.id";
$result=rportalrequete($query) or rportalerreur("ERREUR : $query","?op=");
while($html=rportalligne($result)){
	$i = 1;
	$TPLN->Parse("fichier.code",$html['code']);
	$TPLN->Parse("fichier.type",$html['type_nom']);
	$TPLN->Parse("fichier.classe",$class);
	if($class!="liste_impaire") 
    { 
        $class="liste_impaire"; 
    }else{ 
        $class="liste_paire"; 
    } 
	
	if($rportalparams->get_value('RPORTAL','recherche.type.'.$html['type_nom'])=='yes'){
		$m = new MoteurIndexation("?op=html&code={$html['code']}");
		$m->setType($html['type']);
		$m->setHTMLID($html['id']);
		$m->setTitre(addslashes($html['titre']));
		$m->setDescription(addslashes($html['description']));
		$new_dest=sprintf("%07d.php", $html['id']);
		if(file_exists("html/$new_dest")){
			$fp = fopen("html/$new_dest", "r");
		  	$content = fread($fp, filesize("html/$new_dest"));
		  	fclose($fp);
			$m->setInit();
			$m->indexer(strip_tags(addslashes($content)));
		}
		$TPLN->Parse("fichier.status","Ok");
	}else{
		$TPLN->Parse("fichier.status","Type non indexable");
	}
	$TPLN->Loop("fichier");
}
if($i==0){
	$TPLN->EraseBloc("fichier");	
}
$TPLN->Write();
?>